package com.netease.pris.activity.view;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnClickListener;
import android.view.View.OnCreateContextMenuListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.widget.FrameLayout;
import com.netease.pris.activity.cr;
import com.netease.pris.atom.u;
import java.util.ArrayList;
import java.util.LinkedList;

public class PRISGridView extends ViewGroup
  implements bp
{
  public static final int a = 2;
  public static final int b = 3;
  public static final int c = 6;
  private static final String d = "PRISGridView";
  private static final int e = -1;
  private Bitmap A;
  private int B;
  private Handler C = new aj(this);
  private cr f;
  private int g;
  private int h;
  private int i = -1;
  private int j = -1;
  private int k = 0;
  private int l = 0;
  private int m = 0;
  private d n;
  private View.OnCreateContextMenuListener o;
  private cb p;
  private View.OnClickListener q = new am(this);
  private View.OnCreateContextMenuListener r = new ak(this);
  private boolean s = false;
  private View t;
  private LinkedList u = new LinkedList();
  private cc v;
  private Rect w = new Rect();
  private Rect x = null;
  private int y = -1;
  private int z = -1;

  public PRISGridView(Context paramContext)
  {
    this(paramContext, null);
  }

  public PRISGridView(Context paramContext, AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, 0);
  }

  public PRISGridView(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
  {
    super(paramContext, paramAttributeSet, paramInt);
    b();
  }

  private int a(String paramString, int paramInt1, int paramInt2)
  {
    int i1;
    if ((TextUtils.isEmpty(paramString)) || (paramInt1 < 0) || (paramInt2 < 0))
      i1 = -1;
    while (true)
    {
      return i1;
      for (int i2 = paramInt1; ; i2++)
      {
        if (i2 > paramInt2)
          break label66;
        if (!((u)this.f.getItem(i2)).V().equals(paramString))
          continue;
        i1 = i2;
        break;
      }
      label66: i1 = -1;
    }
  }

  private View a(int paramInt1, int paramInt2, boolean paramBoolean)
  {
    Rect localRect = this.w;
    int i1 = paramInt1 + getScrollX();
    int i2 = paramInt2 + getScrollY();
    int i3 = getChildCount();
    View localView;
    if (i3 >= 0)
    {
      localView = getChildAt(i3);
      if ((localView == null) || (localView.getVisibility() != 0) || ((localView == this.t) && (!paramBoolean)));
      do
      {
        i3--;
        break;
        localView.getHitRect(localRect);
      }
      while (!localRect.contains(i1, i2));
    }
    while (true)
    {
      return localView;
      localView = null;
    }
  }

  private void a(MotionEvent paramMotionEvent)
  {
    int i1 = (int)paramMotionEvent.getX();
    int i2 = (int)paramMotionEvent.getY();
    switch (paramMotionEvent.getAction())
    {
    default:
    case 0:
    case 2:
    case 1:
    }
    while (true)
    {
      return;
      if ((this.t != null) || (!this.u.isEmpty()) || (this.C.hasMessages(-1)))
        continue;
      this.t = a(i1, i2, true);
      if (this.t == null)
        continue;
      this.y = (i1 - this.t.getLeft());
      this.z = (i2 - this.t.getTop());
      this.x = new Rect(this.t.getLeft(), this.t.getTop(), this.t.getLeft() + this.t.getWidth(), this.t.getTop() + this.t.getHeight());
      a(this.t, (int)paramMotionEvent.getRawX(), (int)paramMotionEvent.getRawY());
      continue;
      if (this.t == null)
        continue;
      b((int)paramMotionEvent.getRawX(), (int)paramMotionEvent.getRawY());
      c(i1, i2);
      continue;
      if (this.t == null)
        continue;
      this.t.layout(this.x.left, this.x.top, this.x.right, this.x.bottom);
      d();
      this.x = null;
      this.t = null;
    }
  }

  private void a(View paramView, int paramInt1, int paramInt2)
  {
    if ((paramView != null) && (this.p != null))
    {
      paramView.setDrawingCacheEnabled(true);
      Bitmap localBitmap = Bitmap.createBitmap(paramView.getDrawingCache());
      this.A = localBitmap;
      this.p.a(paramInt1 - this.y, paramInt2 - this.z, localBitmap);
    }
    paramView.setVisibility(4);
  }

  private void a(View paramView1, View paramView2)
  {
    if ((paramView1 == null) || (paramView2 == null) || (paramView1 == paramView2))
      return;
    int i1 = ((Integer)paramView1.getTag()).intValue();
    int i2 = ((Integer)paramView2.getTag()).intValue();
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    Rect localRect1 = new Rect(this.x);
    if (i1 < i2)
      for (int i4 = i1 + 1; i4 <= i2; i4++)
      {
        Rect localRect3 = new Rect();
        View localView2 = m(i4);
        localRect3.set(localView2.getLeft(), localView2.getTop(), localView2.getRight(), localView2.getBottom());
        localArrayList2.add(new at(this, localView2, localRect3, localRect1));
        localArrayList1.add(localView2);
        localRect1 = new Rect(localRect3);
      }
    for (int i3 = i1 - 1; i3 >= i2; i3--)
    {
      Rect localRect2 = new Rect();
      View localView1 = m(i3);
      localRect2.set(localView1.getLeft(), localView1.getTop(), localView1.getRight(), localView1.getBottom());
      localArrayList2.add(new at(this, localView1, localRect2, localRect1));
      localArrayList1.add(localView1);
      localRect1 = new Rect(localRect2);
    }
    localArrayList1.add(paramView1);
    if (i1 < i2);
    for (boolean bool = true; ; bool = false)
    {
      a(localArrayList1, i1, 1, bool);
      a(localArrayList2);
      break;
    }
  }

  private void a(ViewGroup paramViewGroup, View paramView)
  {
    if ((paramViewGroup == null) || (paramView == null));
    while (true)
    {
      return;
      if (paramView.getParent() == null)
      {
        paramViewGroup.addView(paramView, new ViewGroup.LayoutParams(-1, -1));
        paramView.setOnClickListener(this.q);
        paramView.setOnCreateContextMenuListener(this.r);
        paramView.setFocusable(true);
        ((RelativeLayoutEx)paramView).a(2130837742);
        continue;
      }
    }
  }

  // ERROR //
  private void a(ArrayList paramArrayList)
  {
    // Byte code:
    //   0: aload_1
    //   1: ifnull +91 -> 92
    //   4: aload_0
    //   5: getfield 95	com/netease/pris/activity/view/PRISGridView:u	Ljava/util/LinkedList;
    //   8: astore_2
    //   9: aload_2
    //   10: monitorenter
    //   11: aload_1
    //   12: invokevirtual 343	java/util/ArrayList:iterator	()Ljava/util/Iterator;
    //   15: astore 4
    //   17: aload 4
    //   19: invokeinterface 348 1 0
    //   24: ifeq +32 -> 56
    //   27: aload 4
    //   29: invokeinterface 351 1 0
    //   34: checkcast 298	com/netease/pris/activity/view/at
    //   37: astore 5
    //   39: aload_0
    //   40: getfield 95	com/netease/pris/activity/view/PRISGridView:u	Ljava/util/LinkedList;
    //   43: aload 5
    //   45: invokevirtual 355	java/util/LinkedList:addLast	(Ljava/lang/Object;)V
    //   48: goto -31 -> 17
    //   51: astore_3
    //   52: aload_2
    //   53: monitorexit
    //   54: aload_3
    //   55: athrow
    //   56: aload_0
    //   57: getfield 95	com/netease/pris/activity/view/PRISGridView:u	Ljava/util/LinkedList;
    //   60: invokevirtual 360	java/lang/Object:notify	()V
    //   63: aload_2
    //   64: monitorexit
    //   65: aload_0
    //   66: getfield 362	com/netease/pris/activity/view/PRISGridView:v	Lcom/netease/pris/activity/view/cc;
    //   69: ifnonnull +23 -> 92
    //   72: aload_0
    //   73: new 364	com/netease/pris/activity/view/cc
    //   76: dup
    //   77: aload_0
    //   78: aconst_null
    //   79: invokespecial 367	com/netease/pris/activity/view/cc:<init>	(Lcom/netease/pris/activity/view/PRISGridView;Lcom/netease/pris/activity/view/am;)V
    //   82: putfield 362	com/netease/pris/activity/view/PRISGridView:v	Lcom/netease/pris/activity/view/cc;
    //   85: aload_0
    //   86: getfield 362	com/netease/pris/activity/view/PRISGridView:v	Lcom/netease/pris/activity/view/cc;
    //   89: invokevirtual 370	com/netease/pris/activity/view/cc:start	()V
    //   92: return
    //
    // Exception table:
    //   from	to	target	type
    //   11	54	51	finally
    //   56	65	51	finally
  }

  private void a(ArrayList paramArrayList, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    if ((paramArrayList == null) || (paramArrayList.size() == 0));
    while (true)
    {
      return;
      if (paramBoolean)
      {
        for (int i2 = 0; i2 < paramArrayList.size(); i2++)
          ((View)paramArrayList.get(i2)).setTag(Integer.valueOf(paramInt1 + i2 * paramInt2));
        continue;
      }
      for (int i1 = 0; i1 < paramArrayList.size(); i1++)
        ((View)paramArrayList.get(i1)).setTag(Integer.valueOf(paramInt1 - i1 * paramInt2));
    }
  }

  private void b()
  {
    Context localContext = getContext();
    FrameLayout localFrameLayout1 = new FrameLayout(localContext);
    FrameLayout localFrameLayout2 = new FrameLayout(localContext);
    FrameLayout localFrameLayout3 = new FrameLayout(localContext);
    FrameLayout localFrameLayout4 = new FrameLayout(localContext);
    FrameLayout localFrameLayout5 = new FrameLayout(localContext);
    FrameLayout localFrameLayout6 = new FrameLayout(localContext);
    addView(localFrameLayout1, 0);
    addView(localFrameLayout2, 1);
    addView(localFrameLayout3, 2);
    addView(localFrameLayout4, 3);
    addView(localFrameLayout5, 4);
    addView(localFrameLayout6, 5);
  }

  private void b(int paramInt1, int paramInt2)
  {
    if (this.p == null);
    while (true)
    {
      return;
      this.p.a(paramInt1 - this.y, paramInt2 - this.z);
    }
  }

  private void c()
  {
    if (this.j >= 0)
      com.netease.image.d.a().a(this.j, 256);
  }

  private void c(int paramInt1, int paramInt2)
  {
    if ((!this.u.isEmpty()) || (this.C.hasMessages(-1)));
    while (true)
    {
      return;
      View localView = a(paramInt1, paramInt2, false);
      if (localView == null)
        continue;
      int i1 = localView.getLeft();
      int i2 = localView.getTop();
      int i3 = localView.getRight();
      int i4 = localView.getBottom();
      a(this.t, localView);
      this.x.set(i1, i2, i3, i4);
    }
  }

  private void d()
  {
    this.t.setVisibility(0);
    if (this.A != null)
    {
      this.A.recycle();
      this.A = null;
    }
    if (this.p != null)
      this.p.a();
  }

  private int k(int paramInt)
  {
    return (View.MeasureSpec.getSize(paramInt) - 1 * this.k) / 2;
  }

  private int l(int paramInt)
  {
    return (View.MeasureSpec.getSize(paramInt) - 2 * this.l) / 3;
  }

  private View m(int paramInt)
  {
    int i1 = getChildCount();
    View localView2;
    if (i1 >= 0)
    {
      localView2 = getChildAt(i1);
      if (localView2 == null);
      do
      {
        i1--;
        break;
      }
      while (((Integer)localView2.getTag()).intValue() != paramInt);
    }
    for (View localView1 = localView2; ; localView1 = null)
      return localView1;
  }

  public int a()
  {
    return this.i;
  }

  protected int a(ViewParent paramViewParent)
  {
    int i1 = 0;
    if (i1 < getChildCount())
      if (getChildAt(i1) != paramViewParent);
    for (int i2 = i1 + 6 * this.i; ; i2 = -1)
    {
      return i2;
      i1++;
      break;
    }
  }

  public Object a(int paramInt1, int paramInt2, Object paramObject)
  {
    return null;
  }

  public void a(int paramInt)
  {
    this.k = paramInt;
  }

  public void a(int paramInt1, int paramInt2)
  {
    this.h = paramInt1;
    this.g = paramInt2;
  }

  public void a(int paramInt, boolean paramBoolean)
  {
  }

  public void a(View.OnCreateContextMenuListener paramOnCreateContextMenuListener)
  {
    this.o = paramOnCreateContextMenuListener;
  }

  public void a(cr paramcr)
  {
    this.f = paramcr;
  }

  public void a(cb paramcb)
  {
    this.p = paramcb;
  }

  public void a(d paramd)
  {
    this.n = paramd;
  }

  public boolean a(String paramString)
  {
    if (this.f == null);
    int i1;
    int i2;
    for (int i4 = 0; ; i4 = 0)
    {
      return i4;
      i1 = 6 * this.i;
      i2 = a(paramString, i1, Math.min(-1 + (i1 + 6), -1 + this.f.a()));
      if (i2 >= 0)
        break;
    }
    FrameLayout localFrameLayout = (FrameLayout)c(i2 - i1);
    if (this.h == this.g);
    for (int i3 = 3; ; i3 = 2)
    {
      a(localFrameLayout, this.f.a(i2, localFrameLayout, localFrameLayout.getChildAt(0), this.j, i3));
      i4 = 1;
      break;
    }
  }

  public void b(int paramInt)
  {
    this.l = paramInt;
  }

  public boolean b(int paramInt1, int paramInt2, Object paramObject)
  {
    return false;
  }

  public boolean b(String paramString)
  {
    int i3;
    if (this.f == null)
      i3 = 0;
    while (true)
    {
      return i3;
      int i1 = 6 * this.i;
      int i2 = a(paramString, i1, Math.min(-1 + (i1 + 6), -1 + this.f.a()));
      if (i2 < 0)
      {
        i3 = 0;
        continue;
      }
      FrameLayout localFrameLayout = (FrameLayout)c(i2 - i1);
      this.f.a(i2, paramString, localFrameLayout.getChildAt(0));
      i3 = 1;
    }
  }

  public View c(int paramInt)
  {
    if ((paramInt < 0) || (paramInt >= 6));
    for (View localView = null; ; localView = getChildAt(paramInt))
      return localView;
  }

  public void d(int paramInt)
  {
    this.i = paramInt;
  }

  public boolean dispatchTouchEvent(MotionEvent paramMotionEvent)
  {
    if (!this.s);
    for (boolean bool = super.dispatchTouchEvent(paramMotionEvent); ; bool = true)
    {
      return bool;
      a(paramMotionEvent);
    }
  }

  public void e(int paramInt)
  {
    this.h = paramInt;
  }

  public void f(int paramInt)
  {
    this.B = paramInt;
  }

  public void g(int paramInt)
  {
    if (this.f == null);
    while (true)
    {
      return;
      c();
      this.j = this.f.a(this.i);
      if (this.h == this.g);
      int i3;
      for (int i1 = 3; ; i1 = 2)
      {
        int i2 = 6 * this.i;
        int i4;
        for (i3 = 0; (i2 <= -1 + this.f.a()) && (i3 < 6); i3 = i4)
        {
          FrameLayout localFrameLayout = (FrameLayout)c(i3);
          localFrameLayout.setVisibility(0);
          a(localFrameLayout, this.f.a(i2, localFrameLayout, localFrameLayout.getChildAt(0), this.j, i1));
          i4 = i3 + 1;
          i2++;
        }
      }
      while (i3 < 6)
      {
        ((FrameLayout)c(i3)).setVisibility(4);
        i3++;
      }
    }
  }

  public void h(int paramInt)
  {
  }

  public void i(int paramInt)
  {
    com.netease.image.d locald = com.netease.image.d.a();
    int i1 = this.j;
    if (paramInt == this.g);
    for (int i2 = 3; ; i2 = 2)
    {
      locald.a(i1, i2);
      return;
    }
  }

  public void j(int paramInt)
  {
    this.m = paramInt;
  }

  protected void onAttachedToWindow()
  {
    super.onAttachedToWindow();
  }

  protected void onDraw(Canvas paramCanvas)
  {
    super.onDraw(paramCanvas);
  }

  protected void onFinishInflate()
  {
    super.onFinishInflate();
  }

  protected void onLayout(boolean paramBoolean, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    for (int i1 = 0; i1 < 3; i1++)
      for (int i2 = 0; i2 < 2; i2++)
      {
        int i3 = i2 + i1 * 2;
        View localView = getChildAt(i3);
        if ((localView == null) || (localView.getVisibility() == 8))
          continue;
        int i4 = localView.getMeasuredWidth();
        int i5 = localView.getMeasuredHeight();
        int i6 = i2 * (i4 + this.k);
        int i7 = i1 * (i5 + this.l);
        localView.layout(i6, i7, i4 + i6, i5 + i7);
        localView.setTag(new Integer(i3));
      }
  }

  protected void onMeasure(int paramInt1, int paramInt2)
  {
    super.onMeasure(paramInt1, paramInt2);
    if (View.MeasureSpec.getMode(paramInt1) != 1073741824)
      throw new IllegalStateException("Workspace can only be used in EXACTLY mode.");
    if (View.MeasureSpec.getMode(paramInt2) != 1073741824)
      throw new IllegalStateException("Workspace can only be used in EXACTLY mode.");
    int i1 = k(paramInt1);
    int i2 = l(paramInt2);
    int i3 = View.MeasureSpec.makeMeasureSpec(i1, -2147483648);
    int i4 = View.MeasureSpec.makeMeasureSpec(i2, -2147483648);
    int i5 = getChildCount();
    for (int i6 = 0; i6 < i5; i6++)
      measureChild(getChildAt(i6), i3, i4);
  }

  public boolean onTouchEvent(MotionEvent paramMotionEvent)
  {
    super.onTouchEvent(paramMotionEvent);
    return true;
  }
}

/* Location:           D:\android\hack\dex2jar-0.0.9.8\classes_dex2jar.jar
 * Qualified Name:     com.netease.pris.activity.view.PRISGridView
 * JD-Core Version:    0.6.0
 */